var app=angular.module('globalapp',[]);
app.config(["$httpProvider", function ($httpProvider) {
    $httpProvider.interceptors.push(function ($rootScope, $q) {
        return {
            'request': function (config) {
                var _html='<div class="ckloading">';
                _html +='<div class="box">';
                _html +='<span class="fa fa-spinner fa-pulse fa-4x"></span>';
				_html +='</div></div>'
				if($('.ckloading')&&$('.ckloading').is(":hidden")){
					$('.ckloading').show();
				}else{
					$(_html).appendTo('body');
				}
                return config || $q.when(config);
            },
            'requestError': function (rejection) {
                return rejection;
            },
            'response': function (response) {
                $('.ckloading').hide();
                return response || $q.when(response);
            },
            'responseError': function (response) {
                $.alert(response.status + ' - ' + response.statusText + '<br/>请求路径：<br/>' + response.config.url, '请求错误');
                $('.ckloading').hide();
                return $q.reject(response);
            }
        };
    });
}]);
